﻿

using AutoMapper;
using PmSoft;
using System.ComponentModel.DataAnnotations;

namespace ManagementApi.Models.App;

/// <summary>
/// app版本控制
///</summary>
public class AppVersionEditForm
{
    /// <summary>
    ///  
    ///</summary>
     [Display(Name="")]
     [Required(ErrorMessage = "{0}不能为空")]
     public int Id { get; set; }
    /// <summary>
    /// 版本号 
    ///</summary>
     [Display(Name="版本号")]
     [Required(ErrorMessage = "{0}不能为空")]
     public int VersionCode { get; set; }
    /// <summary>
    /// 版本名称 
    ///</summary>
     [Display(Name="版本名称")]
     [Required(ErrorMessage = "{0}不能为空")]
     public string VersionName { get; set; }
    /// <summary>
    /// 下载地址 
    ///</summary>
     [Display(Name="下载地址")]
     [Required(ErrorMessage = "{0}不能为空")]
     public string DownloadUrl { get; set; }
    /// <summary>
    /// Apk大小（单位：KB） 
    ///</summary>
     [Display(Name="Apk大小（单位：KB）")]
     [Required(ErrorMessage = "{0}不能为空")]
     public int ApkSize { get; set; }
    /// <summary>
    /// Apk Md5密钥 
    ///</summary>
     [Display(Name="Apk Md5密钥")]
     [Required(ErrorMessage = "{0}不能为空")]
     public string ApkMd5 { get; set; }
    /// <summary>
    /// 上传时间 
    ///</summary>
     [Display(Name="上传时间")]
     [Required(ErrorMessage = "{0}不能为空")]
     public DateTime UploadTime { get; set; }
    /// <summary>
    /// 说明 
    ///</summary>
     [Display(Name="说明")]
     [Required(ErrorMessage = "{0}不能为空")]
     public string ModifyContent { get; set; }
    /// <summary>
    /// 支持机型，用,隔开，如(a,b,c,d)，若为空则所有机型 
    ///</summary>
     [Display(Name="支持机型")]
     [Required(ErrorMessage = "{0}不能为空")]
     public string SupportedModels { get; set; }
    /// <summary>
    /// 创建时间 
    ///</summary>
     [Display(Name="创建时间")]
     [Required(ErrorMessage = "{0}不能为空")]
     public DateTime CreateTime { get; set; }

#region 扩展字段

//这里自行增加扩展字段，如 项目名称

#endregion
}

public static class AppVersionExtensions
{
  public static AppVersionEditForm AsForm(this Modules.AppVersion entity)
  {
      AppVersionEditForm form = new();
      var mapper = ServiceAccessor.GetService<IMapper>();
      mapper.Map(entity, form);
      #region 这里给扩展字段赋值
      #endregion
      return form;
  }
}
